package com.locatech.dynamic.test;

import java.util.List;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.locatech.dynamic.datasource.DataSourceBeanBuilder;
import com.locatech.dynamic.datasource.DataSourceContext;
import com.locatech.dynamic.entity.Instance;
import com.locatech.dynamic.mapper.InstanceDao;


public class mytest{

	    InstanceDao ds;
	    Instance myds;
		@Test
		public void test(){
			//改变数据库前
			ApplicationContext applicationContext = new FileSystemXmlApplicationContext("classpath:applicationContext.xml"); 
			ds = applicationContext.getBean(InstanceDao.class);
			System.out.println(ds);
			myds =ds.getInstanceById("");
			System.out.println(myds);
			//改变数据库后
			DataSourceBeanBuilder dataSourceBeanBuilder = new DataSourceBeanBuilder("localhost", 
	    			"127.0.0.1","3306","dynamic","root","root");
			DataSourceContext.setDataSource(dataSourceBeanBuilder);
			ApplicationContext applicationContext1 = new FileSystemXmlApplicationContext("classpath:applicationContext.xml"); 
			ds = applicationContext1.getBean(InstanceDao.class);
			System.out.println(ds);
			myds =ds.getInstanceById("");
			System.out.println(myds);
		
		}

	
		 	
	}
	
	

